package com.afkt.project.ui.slice;


import com.afkt.project.base.app.BaseActivity;
import com.afkt.project.model.bean.ItemBean;
import com.afkt.project.ui.adapter.PagerSnapAdapter;
import com.ohos.afkt.ResourceTable;
import ohos.aafwk.content.Intent;
import ohos.agp.components.*;

import java.util.ArrayList;
import java.util.List;

public class PagerSnapActivity extends BaseActivity {


    private ListContainer vidBvrRecy;


    private DirectionalLayout bar_Layout;
    private DirectionalLayout bar;
    private Image select_retuen;

    @Override
    protected void onStart(Intent intent) {
        super.onStart(intent);
        bar_Layout = (DirectionalLayout) findComponentById(ResourceTable.Id_base_view_barLayout);
        bar = (DirectionalLayout) LayoutScatter.getInstance(this).parse(ResourceTable.Layout_sheet_dialog_bar, null, false);
        Text text = (Text) bar.findComponentById(ResourceTable.Id_titleText);
        select_retuen = (Image) bar.findComponentById(ResourceTable.Id_sheet_dialog_return);
        text.setText("LinearSnapHelper-RecyclerView");
        bar_Layout.addComponent(bar);
        vidBvrRecy = (ListContainer) findComponentById(ResourceTable.Id_vid_bvr_recy);
        initValue();
    }

    @Override
    protected int baseLayoutId() {
        return ResourceTable.Layout_activity_page_snap;
    }

    @Override
    protected void initView() {

    }

    @Override
    protected void initListener() {
        select_retuen.setClickedListener(component -> {
            // LogUtils.error(TAG, "return 点击");
            onBackPressed();
        });

    }


    @Override
    protected void onBackground() {
        super.onBackground();
        bar_Layout.removeAllComponents();
}

    private void initValue() {
        List<ItemBean> lists = new ArrayList<>();
        for (int i = 0; i <= 9; i++) {
            lists.add(ItemBean.newItemBeanPager());
        }

        PagerSnapAdapter pagerSnapAdapter = new PagerSnapAdapter(lists, this);
/*        LayoutManager layoutManager = new DirectionalLayoutManager();
        layoutManager.setOrientation(Component.HORIZONTAL);
        vidBvrRecy.setLayoutManager(layoutManager);*/
        vidBvrRecy.setItemProvider(pagerSnapAdapter);
    }
}
